<?php
Class C_utility extends Cemvc_Control_Base
{
  public function __construct()
  {
    parent::__construct();
  }

  public function redirect()
  {
    if (isset($_REQUEST["oauth"]) && $_REQUEST["oauth"])
      {
	if ($_REQUEST["oauth"] == OAUTH_TYPE_QQ)
	  {
	    $_SESSION['oauth'] = OAUTH_TYPE_QQ;
	    $to = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=".OAUTH_QQ_APP_KEY."&redirect_uri=".OAUTH_QQ_REDIRECT_URI;
	  }
	else if ($_REQUEST["oauth"] == OAUTH_TYPE_WEIBO)
	  {
	    $_SESSION['oauth'] = OAUTH_TYPE_WEIBO;
	    $to = "https://api.weibo.com/oauth2/authorize?client_id=".OAUTH_SINA_APP_KEY."&response_type=code&redirect_uri=".OAUTH_SINA_REDIRECT_URI;
	  }
	else if ($_REQUEST["oauth"] == OAUTH_TYPE_KAIXIN)
	  {
	    $_SESSION['oauth'] = OAUTH_TYPE_KAIXIN;
	    $to = "http://api.kaixin001.com/oauth2/authorize?response_type=code&client_id=".OAUTH_KAIXIN_APP_KEY."&redirect_uri=".OAUTH_KAIXIN_REDIRECT_URI."&scope=basic&display=popup";
	  }
	else if ($_REQUEST["oauth"] == OAUTH_TYPE_RENREN)
	  {
	    $_SESSION['oauth'] = OAUTH_TYPE_RENREN;
	    $to = "https://graph.renren.com/oauth/authorize?client_id=".OAUTH_RENREN_APP_KEY."&redirect_uri=".OAUTH_RENREN_REDIRECT_URI."&response_type=code";
	  }
	header("Location: ".$to);
	die("location ".$to);
      } 
  }

}
